<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>浅拷贝</title>
</head>
<body>
    <script>
        // 浅拷贝，就是浅层的复制, 复制就是值一样，但是相互独立互补影响
        // 深拷贝，就是深层复制

        let obj = {
            name:'顾亚林',
            age: 19,
            city:'廊坊',
            address:{
                street:'中山路',
                hello:function(){
                    console.log(hello);
                }
            },
            say:function(){
                console.log(123);
            }
        }

        let target = {};

        Object.assign(target,obj);
        console.log('obj',obj);
        console.log('target',target);

        target.name = '顾攻城狮';
        target.address.street = '城房子村 6乡3户2委';
        target.say = function(){
            console.log(222);
        }

        console.log(target,obj);
        console.log(target.address === obj.address);

        target.say();
        obj.say();
    </script>
</body>
</html>